/*
 * Copyright (c) 2014 laidian. All Rights Reserved.
 * @author yaoyuming
 * @date  2020-03-13 15:20
 */
package com.yao.fin.entity.dto;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yao.fin.entity.FinancialTemplateEntity;
import com.yao.fin.enums.CourseBase;
import com.yao.fin.enums.LabelEnum;
import com.yao.fin.enums.SingleEnum;
import lombok.Data;

/**
 * @author yaoyuming
 * @date 2020/03/13 15:20
 */
@Data
@TableName("fin_financial_template")
public class FinancialTemplateDto extends FinancialTemplateEntity {

    @TableField(exist = false)
    private String labelDesc;

    @TableField(exist = false)
    private String singleDesc;

    @TableField(exist = false)
    private String courseDesc;


    public FinancialTemplateDto fill(){
        labelDesc = LabelEnum.getDesc(getLabel());
        singleDesc = SingleEnum.getDesc(getSingle());

        if(LabelEnum.ZJ.getCode() == getLabel()){
            courseDesc = CourseBase.ZJEnum.getDesc(getCourse());
        }else if(LabelEnum.CPA.getCode() == getLabel()){
            courseDesc = CourseBase.CPAEnum.getDesc(getCourse());
        }

        return this;
    }

    public static FinancialTemplateDto of(FinancialTemplateEntity entity){
        FinancialTemplateDto dto = new FinancialTemplateDto();
        BeanUtil.copyProperties(entity, dto);
        return dto;
    }


}